Tutorial 3 - Line following
Download the zip file here
To initialize the ground sensors:
gs = []
gsNames = ['gs0', 'gs1', 'gs2']
for i in range(3):
gs.append(robot.getDevice(gsNames[i]))
gs[i].enable(timestep)
To read the ground sensors inside the main loop:
gsValues = []
for i in range(3):
gsValues.append(gs[i].getValue())
To read sensor values inside the main loop:
line_right = gsValues[0]
line_center = gsValues[1]
line_left = gsValues[2]
Complete the line following robot coding using using state-machine code